$(function(){
	
		
		$("#pro-sel-ul li").on("mouseenter",function(){
			$(this).addClass("hover").siblings().removeClass("hover");
			var which = $(this).index();
			$("#pro-sel-show .pro-sel-show-item")
			.eq(which).removeClass("hide")
			.siblings().addClass("hide");
		});
	

	$("#pro-sel").on("mouseleave",function(){
		$("#pro-sel-ul li").removeClass("hover");
		$("#pro-sel-show .pro-sel-show-item").addClass("hide");
	});


	//这下面开始轮播图代码
	var timer = null;
	var index = 1;
	var curindex = 0;
	var flag = true;

	//首尾加一张，形成无缝
	var len = $("#lunbotu li").length;
	$("#lunbotu").prepend($("#lunbotu li").eq(len-1).clone(true));
	$("#lunbotu").append($("#lunbotu li").eq(1).clone(true));

	//正常的向右播放代码
	function play(){
		
            index++;
            curindex++;

            if(index > 3){
            	index = 1;
            	$("#lunbotu").css({
            		"left": "0px"
            	});
            }

			$("#lunbotu").stop().animate({
				"left": -index*1200 + "px"
			},800);

			if(curindex > 2){
                curindex = 0;
            }

            selcar(curindex);
            backcol(index);
              
        }

     //这个轮播图控制圆点的代码
    function selcar(index){
    	$("#car-cont span").eq(index).addClass("cur").siblings().removeClass("cur");
    }

    //这个控制背景色的
    function backcol(index){
    	 var carcol = $("#lunbotu li").eq(index).data("col");
            setTimeout(function(){
            	$("#carouselpart").css({
            		"background-color": carcol
            	});
            },200);
    }    

	timer = setInterval(play,2000);


	//大盒子移入清除定时器，移开触发定时器
	$("#car-show").on("mouseenter",function(){
		clearInterval(timer);
	});
	$("#car-show").on("mouseleave",function(){
		timer = setInterval(play,2000);
	});

	//圆点点击切换
	$("#car-cont span").on("click",function(){
		index = $(this).index()+1;
		curindex = $(this).index();

		 $("#lunbotu").stop().animate({
				"left": -index*1200 + "px"
			},800);

		 selcar(curindex);
		 backcol(index);
	});

	//点击右边按钮，切换下一张，就这个开始出问题
	$("#car-next").on("click",function(){
		play();
	});

	$("#car-pre").on("click",function(){
		index--;
		curindex--;
		if(index < 0){
			index = 2;
            $("#lunbotu").css({
            	"left": "-3600px"
            });
		}
		 $("#lunbotu").stop().animate({
				"left": -index*1200 + "px"
		},800);
		 if(curindex < 0){
		 	curindex = 2;
		 }
		  selcar(curindex);
		  backcol(index);
	});


	
	

})